package com.ok.utils;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;

import javax.websocket.Session;

public class SessionUtils {
    /**
     * 从session中获取参数值
     */
    public static String getReqParamValue(Session session, String paramName) {
        if (MapUtil.isEmpty(session.getRequestParameterMap())) {
            return null;
        }

        if (!session.getRequestParameterMap().containsKey(paramName)) {
            return null;
        }

        if (CollUtil.isEmpty(session.getRequestParameterMap().get(paramName))) {
            return null;
        }
        return session.getRequestParameterMap().get(paramName).get(0);
    }
}
